package com.teamwork.demo.controller;

import com.hit.demo1.entity.E_Stu;
import com.hit.demo1.param.StuParam;
import com.teamwork.demo.entity.Application;
import com.teamwork.demo.entity.Stu;
import com.teamwork.demo.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class AdminController {
    @Autowired
    public AdminService adminService;

    @GetMapping("/findallpage")
    @ResponseBody
    public Page findAll(StuParam stuParam, int page, int limit){
        return adminService.findAll(stuParam, page, limit);
    }

    @GetMapping("/save")
    @ResponseBody
    public String save(Integer sid, String sgroup, String sgrade){
        return adminService.save(sid, sgroup, sgrade).toString();
    }

    @GetMapping("/update")
    @ResponseBody
    public String update(Stu stu){
        return adminService.update(stu).toString();
    }
    @GetMapping("/delete")
    @ResponseBody
    public String delete(Integer id){
        adminService.delete(id);
        return "ok";
    }
    @GetMapping("/savegroup")
    @ResponseBody
    public String saveGroup(Integer gid,String member1, String member2, String member3, String member4, String member5){
        return adminService.createGroup(gid, member1, member2, member3, member4, member5).toString();

    }
    @GetMapping("/savecon")
    @ResponseBody
    public String savecon(Integer sid, String scondition){
        return adminService.savecon(sid, scondition).toString();
    }


}
